﻿@{
    Layout = "~/Views/Shared/_PageLayout.cshtml";
}

@model Beway.ValueAdded.Model.ReUserFinance
@section HeadSection
{
    <script type="text/javascript">
        var role = "@Session["role"]";
        var url = "";
        $(function () {
            $('#FinanceList').datagrid({
                title: '账务管理',
                iconCls: 'icon-edit',
                url: '/ReUserFinance/PagedList',
                striped: true,
                idField: 'FId',
                border: true,
                loadMsg: '数据加载中...',
                singleSelect: true,
                pagination: true,
                pageSize: 20,
                pageList: [15, 20],
                frozenColumns: [[{ field: 'ck', checkbox: true }]],
                columns: [[
                    { field: 'FId', title: 'ID', width: 50, align: 'center', hidden:true },
                        { field: 'ReUserTitle', title: '项目名称', width: 200 },
                        {
                            field: 'Amount', title: '追加金额', width: 80, align: 'center'
                        },
                        { field: 'Total', title: '剩余/累计金额', width: 120, align: 'center', formatter: function (val, rec) {
                            return rec.Balance + "/" + val;
                        } },
                        { field: 'AdminUser', title: '操作管理员', width: 110, align: 'center' },
                        { field: 'Remark', title: '备注', width: 180, align: 'center' },                         
                        {
                            field: 'AddTime', title: '增加时间', width: 120, align: 'center', formatter: function (val, rec) {
                                return JSONDateToJSDate(val);
                            }
                        }
                ]], toolbar: [{
                    text: '追加费用',
                    iconCls: 'icon-add',
                    handler: function () {
                        add();
                    }
                }, '-']

            });

            //尺寸
            $('#FinanceList').datagrid('resize');

            //加载搜索框//在这个样式下。加载搜索框的div
            $(".datagrid-toolbar").append($("#divsearch"));

            //绑定项目
            bindReUserCombogrid("ReUser");
            bindReUserCombogrid("ReUserId");
        });

        //搜索
        function doSearch() {
            $('#FinanceList').datagrid('load', { userId: $("#ReUser").combogrid("getValue") });
        }

        //新增
        function add() {
            //if (role == 0) {               
                url = "/ReUserFinance/add";
                $("#dlg").dialog('open').dialog('setTitle', '项目追加费用');
                $("#fm").form('clear');
            //}
            //else
            //{
             //   alert("抱歉，项目经理不能为项目追加费用。");
            //}
        }
        //新增确定
        function save() {
            $.messager.progress();
            $("#fm").form('submit', {
                url: url,
                onSubmit: function () {

                    if (!$(this).form('validate')) {
                        $.messager.progress('close');
                        return false;
                    }
                },
                success: function (result) {
                    $.messager.progress('close');
                    if (result > 0) {
                        $("#dlg").dialog('close');
                        $.messager.alert('提示', '信息保存成功');
                        $("#FinanceList").datagrid('reload');
                    } else   {
                        $.messager.show({
                            title: 'Error',
                            msg: "追加费用失败，请重试"
                        }
                        );
                    }
                }
            });
        }        
    </script>
}
<div id="divsearch">
    项目名称：<input type="text" name="ReUser" id="ReUser" style="width: 180px" />
    <a href="#" class="easyui-linkbutton" onclick="doSearch();" iconcls="icon-search">搜索</a>
</div>
<table id="FinanceList" toolbar="#divsearch"></table>
<div id="dlg-buttons">
    <a href="#" class="easyui-linkbutton" iconcls="icon-ok" onclick="save()">保存</a>
    <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>
<div id="dlg" class="easyui-dialog" style="width: 800px; padding: 10px 10px" resizable="true"
     closed="true" modal="true" buttons="#dlg-buttons">
    <form id="fm" method="post" enctype="multipart/form-data">
        <div class="fitem">
            <label>项目名称：</label>
            @Html.TextBoxFor(m => m.ReUserId, new { @class = "easyui-combogrid", @style = "width:200px;", @required = "true" })
        </div>
        <div class="fitem">
            <label>追加金额：</label>
            @Html.TextBoxFor(m => m.Amount, new {  @class = "easyui-numberbox", @precision = "2", @style = "width:200px;", @maxlength = "200",@required = "true" }) 追加的充值费用
        </div>
        <div class="fitem">
            <label>备注：</label>
            @Html.TextBoxFor(m => m.Remark, new { @class = "easyui-validatebox", @style = "width:250px;", @maxlength = "50" }) 
            <span>注意：此处追加的金额，在充值时是以实际面值去扣减，未包含税费。</span>
        </div>
       
    </form>
</div>

